#!/bin/sh
#ubuntu is the problem, these symlinks are missing...

if [ ! -e usr/bin/g++ ];then
	REALFILE="`find usr/bin/ -maxdepth 1 -type f -name "g++-[0-9]*" | head -n 1 | rev | cut -f 1 -d '/' | rev`"
	# Ubuntu now names the files {ARCH}-linux-gnu-g++-[0-9]
	[ "$REALFILE" = "" ] && REALFILE="`find usr/bin/ -maxdepth 1 -type f -name "*-linux-gnu-g++-[0-9]" | head -n 1 | rev | cut -f 1 -d '/' | rev`"
	ln -sv $REALFILE usr/bin/g++
fi

if [ ! -e usr/bin/gcc ];then
	REALFILE="`find usr/bin/ -maxdepth 1 -type f -name "gcc-[0-9]*" | head -n 1 | rev | cut -f 1 -d '/' | rev`"
	# Ubuntu now names the files {ARCH}-linux-gnu-gcc-[0-9]
	[ "$REALFILE" = "" ] && REALFILE="`find usr/bin/ -maxdepth 1 -type f -name "*-linux-gnu-gcc-[0-9]" | head -n 1 | rev | cut -f 1 -d '/' | rev`"
	ln -sv $REALFILE usr/bin/gcc
fi

if [ ! -e usr/bin/c++ ] ; then
	ln -sv g++ usr/bin/c++
fi

if [ ! -e usr/bin/cc ] ; then
	ln -sv gcc usr/bin/cc
fi

find usr/${PLIB} -mindepth 1 -maxdepth 2 -iname 'libstdc*.py' -delete
